﻿using System;
using System.Threading;
using BitTorrent.Client;
using BitTorrent.Client.Peer;
using BitTorrent.Client.Peer.Message.Standard;
using BitTorrent.File;
using MbUnit.Framework;
using Microsoft.Ccr.Core;

namespace UnitTest.Client {
    /// <summary>
    /// Summary description for PeerConnectionTest
    /// </summary>
    [TestFixture]
    public class PeerConnectionTest {
        private PeerListenerAgent _listenerAgent;
        private DispatcherQueue _queue;
        private Dispatcher _dispatcher;

        public PeerConnectionTest() {
            // Dispatcher this test will use.
            _dispatcher = new Dispatcher();
            _queue = new DispatcherQueue("Test", _dispatcher);
            // 1) Create a PeerListener
            _listenerAgent = new PeerListenerAgent(_queue);
        }

        [Test]
        public void TestPeerListener() {
            var peerConnection = new PeerConnection(new TestPeer(), _queue);
            var handshake = new Handshake {PeerId = new PeerId(), ProtocolString = "BitTorrent protocol"};
            peerConnection.Port.Post(handshake);

        }

        [Test]
        public void TestMethod1() {
            var dispatcher = new Dispatcher();
            var client = new ClientAgent(dispatcher);
            client.Port.Post(new AddTorrent { TorrentMetaFile = new MetaFile(@"C:\Users\fen\Desktop\BNBT\torrents\CES2009Win72_on10.mp4.mp4.torrent") });

            Thread.Sleep(new TimeSpan(0, 0, 4, 0));
        }
    }
}
